// Upgrade NOTE: commented out 'float4 unity_LightmapST', a built-in variable
// Upgrade NOTE: commented out 'sampler2D unity_Lightmap', a built-in variable
// Upgrade NOTE: replaced tex2D unity_Lightmap with UNITY_SAMPLE_TEX2D

Shader "Legacy Shaders/VertexLit"
{
  Properties
  {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SpecColor ("Spec Color", Color) = (1,1,1,1)
    _Emission ("Emissive Color", Color) = (0,0,0,0)
    [PowerSlider(5.0)] _Shininess ("Shininess", Range(0.01, 1)) = 0.7
    _MainTex ("Base (RGB)", 2D) = "white" {}
  }
  SubShader
  {
    Tags
    { 
      "RenderType" = "Opaque"
    }
    LOD 100
    Pass // ind: 1, name: 
    {
      Tags
      { 
        "LIGHTMODE" = "Vertex"
        "RenderType" = "Opaque"
      }
      LOD 100
      Fog
      { 
        Mode  Off
      } 
      GpuProgramID 182387
      // m_ProgramMask = 6
      CGPROGRAM
      //#pragma target 4.0
      
      #pragma vertex vert
      #pragma fragment frag
      
      #include "UnityCG.cginc"
      
      #define conv_mxt4x4_0(mat4x4) float4(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x,mat4x4[3].x)
      #define conv_mxt4x4_1(mat4x4) float4(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y,mat4x4[3].y)
      #define conv_mxt4x4_2(mat4x4) float4(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z,mat4x4[3].z)
      #define conv_mxt4x4_3(mat4x4) float4(mat4x4[0].w,mat4x4[1].w,mat4x4[2].w,mat4x4[3].w)
      #define conv_mxt3x3_0(mat4x4) float3(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x)
      #define conv_mxt3x3_1(mat4x4) float3(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y)
      #define conv_mxt3x3_2(mat4x4) float3(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z)
      
      #define CODE_BLOCK_VERTEX
      //uniform float4 unity_LightColor[8];
      //uniform float4 unity_LightPosition[8];
      //uniform float4x4 unity_ObjectToWorld;
      //uniform float4x4 unity_WorldToObject;
      //uniform float4 glstate_lightmodel_ambient;
      //uniform float4x4 unity_MatrixV;
      //uniform float4x4 unity_MatrixInvV;
      //uniform float4x4 unity_MatrixVP;
      uniform float4 _Color;
      uniform float4 _SpecColor;
      uniform float4 _Emission;
      uniform float _Shininess;
      uniform float4 _MainTex_ST;
      uniform sampler2D _MainTex;
      struct IN_Data_Vert
      {
          float4 in_POSITION :POSITION;
          float3 in_NORMAL :NORMAL;
          float4 in_TEXCOORD0 :TEXCOORD0;
      };
      
      struct OUT_Data_Vert
      {
          float4 xlv_COLOR0 :COLOR0;
          float3 xlv_COLOR1 :COLOR1;
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float4 gl_Position :SV_POSITION;
      };
      
      struct IN_Data_Frag
      {
          float4 xlv_COLOR0 :COLOR0;
          float3 xlv_COLOR1 :COLOR1;
          float2 xlv_TEXCOORD0 :TEXCOORD0;
      };
      
      struct OUT_Data_Frag
      {
          float4 SV_Target0 :SV_Target0;
      };
      
      OUT_Data_Vert vert(IN_Data_Vert in_v)
      {
          OUT_Data_Vert out_v;
          float4x4 m_1;
          m_1 = mul(unity_WorldToObject, unity_MatrixInvV);
          float4 tmpvar_2;
          float4 tmpvar_3;
          float4 tmpvar_4;
          tmpvar_2.x = m_1[0].x;
          tmpvar_2.y = m_1[1].x;
          tmpvar_2.z = m_1[2].x;
          tmpvar_2.w = m_1[3].x;
          tmpvar_3.x = m_1[0].y;
          tmpvar_3.y = m_1[1].y;
          tmpvar_3.z = m_1[2].y;
          tmpvar_3.w = m_1[3].y;
          tmpvar_4.x = m_1[0].z;
          tmpvar_4.y = m_1[1].z;
          tmpvar_4.z = m_1[2].z;
          tmpvar_4.w = m_1[3].z;
          float3 tmpvar_5;
          tmpvar_5 = in_v.in_POSITION.xyz;
          float shininess_7;
          float3 specColor_8;
          float3 lcolor_9;
          float3 viewDir_10;
          float3 eyeNormal_11;
          float4 color_12;
          color_12 = float4(0, 0, 0, 1.1);
          float4 tmpvar_13;
          tmpvar_13.w = 1;
          tmpvar_13.xyz = tmpvar_5;
          float3x3 tmpvar_14;
          tmpvar_14[0] = tmpvar_2.xyz;
          tmpvar_14[1] = tmpvar_3.xyz;
          tmpvar_14[2] = tmpvar_4.xyz;
          float3 tmpvar_15;
          tmpvar_15 = normalize(mul(tmpvar_14, in_v.in_NORMAL));
          eyeNormal_11 = tmpvar_15;
          float3 tmpvar_16;
          //tmpvar_16 = normalize((mul(unity_MatrixV, unity_ObjectToWorld) * tmpvar_13).xyz);
          tmpvar_16 = normalize(mul(tmpvar_14, in_v.in_NORMAL));
          viewDir_10 = (-tmpvar_16);
          lcolor_9 = (_Emission.xyz + (_Color.xyz * glstate_lightmodel_ambient.xyz));
          specColor_8 = float3(0, 0, 0);
          shininess_7 = (_Shininess * 128);
          int il_6 = 0;
          while((il_6<8))
          {
              float3 tmpvar_17;
              tmpvar_17 = unity_LightPosition[0].xyz;
              float3 dirToLight_18;
              dirToLight_18 = tmpvar_17;
              float3 specColor_19;
              specColor_19 = specColor_8;
              float tmpvar_20;
              tmpvar_20 = max(dot(eyeNormal_11, dirToLight_18), 0);
              float3 tmpvar_21;
              tmpvar_21 = ((tmpvar_20 * _Color.xyz) * unity_LightColor[0].xyz);
              if((tmpvar_20>0))
              {
                  specColor_19 = (specColor_8 + ((0.5 * clamp(pow(max(dot(eyeNormal_11, normalize((dirToLight_18 + viewDir_10))), 0), shininess_7), 0, 1)) * unity_LightColor[0].xyz));
              }
              specColor_8 = specColor_19;
              lcolor_9 = (lcolor_9 + min((tmpvar_21 * 0.5), float3(1, 1, 1)));
              il_6 = (il_6 + 1);
          }
          color_12.xyz = lcolor_9;
          color_12.w = _Color.w;
          specColor_8 = (specColor_8 * _SpecColor.xyz);
          float4 tmpvar_22;
          float4 tmpvar_23;
          tmpvar_23 = clamp(color_12, 0, 1);
          tmpvar_22 = tmpvar_23;
          float3 tmpvar_24;
          float3 tmpvar_25;
          tmpvar_25 = clamp(specColor_8, 0, 1);
          tmpvar_24 = tmpvar_25;
          float4 tmpvar_26;
          tmpvar_26.w = 1;
          tmpvar_26.xyz = tmpvar_5;
          out_v.xlv_COLOR0 = tmpvar_22;
          out_v.xlv_COLOR1 = tmpvar_24;
          out_v.xlv_TEXCOORD0 = ((in_v.in_TEXCOORD0.xy * _MainTex_ST.xy) + _MainTex_ST.zw);
          out_v.gl_Position = mul(unity_MatrixVP, mul(unity_ObjectToWorld, tmpvar_26));
          return out_v;
      }
      
      #define CODE_BLOCK_FRAGMENT
      OUT_Data_Frag frag(IN_Data_Frag in_f)
      {
          OUT_Data_Frag out_f;
          float4 col_1;
          col_1.xyz = (tex2D(_MainTex, in_f.xlv_TEXCOORD0) * in_f.xlv_COLOR0).xyz;
          col_1.xyz = (col_1 * 2).xyz;
          col_1.w = 1;
          col_1.xyz = (col_1.xyz + in_f.xlv_COLOR1);
          out_f.SV_Target0 = col_1;
          return out_f;
      }
      
      
      ENDCG
      
    } // end phase
    Pass // ind: 2, name: 
    {
      Tags
      { 
        "LIGHTMODE" = "VertexLM"
        "RenderType" = "Opaque"
      }
      LOD 100
      GpuProgramID 21925
      // m_ProgramMask = 6
      CGPROGRAM
      //#pragma target 4.0
      
      #pragma vertex vert
      #pragma fragment frag
      
      #include "UnityCG.cginc"
      
      #define conv_mxt4x4_0(mat4x4) float4(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x,mat4x4[3].x)
      #define conv_mxt4x4_1(mat4x4) float4(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y,mat4x4[3].y)
      #define conv_mxt4x4_2(mat4x4) float4(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z,mat4x4[3].z)
      #define conv_mxt4x4_3(mat4x4) float4(mat4x4[0].w,mat4x4[1].w,mat4x4[2].w,mat4x4[3].w)
      #define conv_mxt3x3_0(mat4x4) float3(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x)
      #define conv_mxt3x3_1(mat4x4) float3(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y)
      #define conv_mxt3x3_2(mat4x4) float3(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z)
      
      #define CODE_BLOCK_VERTEX
      //uniform float4x4 unity_ObjectToWorld;
      //uniform float4x4 unity_MatrixVP;
      // uniform float4 unity_LightmapST;
      uniform float4 unity_Lightmap_ST;
      uniform float4 _MainTex_ST;
      // uniform sampler2D unity_Lightmap;
      //uniform float4 unity_Lightmap_HDR;
      uniform sampler2D _MainTex;
      uniform float4 _Color;
      struct IN_Data_Vert
      {
          float4 in_POSITION :POSITION;
          float4 in_TEXCOORD0 :TEXCOORD0;
          float4 in_TEXCOORD1 :TEXCOORD1;
      };
      
      struct OUT_Data_Vert
      {
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float2 xlv_TEXCOORD1 :TEXCOORD1;
          float2 xlv_TEXCOORD2 :TEXCOORD2;
          float4 gl_Position :SV_POSITION;
      };
      
      struct IN_Data_Frag
      {
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float2 xlv_TEXCOORD2 :TEXCOORD2;
      };
      
      struct OUT_Data_Frag
      {
          float4 SV_Target0 :SV_Target0;
      };
      
      OUT_Data_Vert vert(IN_Data_Vert in_v)
      {
          OUT_Data_Vert out_v;
          float4 tmpvar_1;
          tmpvar_1.w = 1;
          tmpvar_1.xyz = in_v.in_POSITION.xyz;
          out_v.xlv_TEXCOORD0 = ((in_v.in_TEXCOORD1.xy * unity_LightmapST.xy) + unity_LightmapST.zw);
          out_v.xlv_TEXCOORD1 = ((in_v.in_TEXCOORD1.xy * unity_Lightmap_ST.xy) + unity_Lightmap_ST.zw);
          out_v.xlv_TEXCOORD2 = ((in_v.in_TEXCOORD0.xy * _MainTex_ST.xy) + _MainTex_ST.zw);
          out_v.gl_Position = mul(unity_MatrixVP, mul(unity_ObjectToWorld, tmpvar_1));
          return out_v;
      }
      
      #define CODE_BLOCK_FRAGMENT
      OUT_Data_Frag frag(IN_Data_Frag in_f)
      {
          OUT_Data_Frag out_f;
          float4 tex_1;
          float4 col_2;
          float4 tmpvar_3;
          tmpvar_3 = UNITY_SAMPLE_TEX2D(unity_Lightmap, in_f.xlv_TEXCOORD0);
          tex_1 = tmpvar_3;
          float4 tmpvar_4;
          tmpvar_4.w = 1;
          tmpvar_4.xyz = (unity_Lightmap_HDR.x * tex_1.xyz);
          col_2 = (tmpvar_4 * _Color);
          float4 tmpvar_5;
          tmpvar_5 = tex2D(_MainTex, in_f.xlv_TEXCOORD2);
          tex_1 = tmpvar_5;
          col_2.xyz = (tmpvar_5.xyz * col_2.xyz);
          col_2.w = 1;
          out_f.SV_Target0 = col_2;
          return out_f;
      }
      
      
      ENDCG
      
    } // end phase
    Pass // ind: 3, name: ShadowCaster
    {
      Name "ShadowCaster"
      Tags
      { 
        "LIGHTMODE" = "SHADOWCASTER"
        "RenderType" = "Opaque"
        "SHADOWSUPPORT" = "true"
      }
      LOD 100
      GpuProgramID 94398
      // m_ProgramMask = 6
      CGPROGRAM
      #pragma multi_compile SHADOWS_DEPTH
      //#pragma target 4.0
      
      #pragma vertex vert
      #pragma fragment frag
      
      #include "UnityCG.cginc"
      
      #define conv_mxt4x4_0(mat4x4) float4(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x,mat4x4[3].x)
      #define conv_mxt4x4_1(mat4x4) float4(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y,mat4x4[3].y)
      #define conv_mxt4x4_2(mat4x4) float4(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z,mat4x4[3].z)
      #define conv_mxt4x4_3(mat4x4) float4(mat4x4[0].w,mat4x4[1].w,mat4x4[2].w,mat4x4[3].w)
      #define conv_mxt3x3_0(mat4x4) float3(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x)
      #define conv_mxt3x3_1(mat4x4) float3(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y)
      #define conv_mxt3x3_2(mat4x4) float3(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z)
      
      #define CODE_BLOCK_VERTEX
      //uniform float4 _WorldSpaceLightPos0;
      //uniform float4 unity_LightShadowBias;
      //uniform float4x4 unity_ObjectToWorld;
      //uniform float4x4 unity_WorldToObject;
      //uniform float4x4 unity_MatrixVP;
      struct IN_Data_Vert
      {
          float4 in_POSITION :POSITION;
          float3 in_NORMAL :NORMAL;
      };
      
      struct OUT_Data_Vert
      {
          float4 gl_Position :SV_POSITION;
      };
      
      struct IN_Data_Frag
      {
      };
      
      struct OUT_Data_Frag
      {
          float4 SV_Target0 :SV_Target0;
      };
      
      OUT_Data_Vert vert(IN_Data_Vert in_v)
      {
          OUT_Data_Vert out_v;
          float4 tmpvar_1;
          float4 wPos_2;
          float4 tmpvar_3;
          tmpvar_3 = mul(unity_ObjectToWorld, in_v.in_POSITION);
          wPos_2 = tmpvar_3;
          if((unity_LightShadowBias.z!=0))
          {
              float3x3 tmpvar_4;
              tmpvar_4[0] = unity_WorldToObject[0].xyz;
              tmpvar_4[1] = unity_WorldToObject[1].xyz;
              tmpvar_4[2] = unity_WorldToObject[2].xyz;
              float3 tmpvar_5;
              tmpvar_5 = normalize(mul(in_v.in_NORMAL, tmpvar_4));
              float tmpvar_6;
              tmpvar_6 = dot(tmpvar_5, normalize((_WorldSpaceLightPos0.xyz - (tmpvar_3.xyz * _WorldSpaceLightPos0.w))));
              wPos_2.xyz = (tmpvar_3.xyz - (tmpvar_5 * (unity_LightShadowBias.z * sqrt((1 - (tmpvar_6 * tmpvar_6))))));
          }
          tmpvar_1 = mul(unity_MatrixVP, wPos_2);
          float4 clipPos_7;
          clipPos_7.xyw = tmpvar_1.xyw;
          clipPos_7.z = (tmpvar_1.z + clamp((unity_LightShadowBias.x / tmpvar_1.w), 0, 1));
          clipPos_7.z = lerp(clipPos_7.z, max(clipPos_7.z, (-tmpvar_1.w)), unity_LightShadowBias.y);
          out_v.gl_Position = clipPos_7;
          return out_v;
      }
      
      #define CODE_BLOCK_FRAGMENT
      OUT_Data_Frag frag(IN_Data_Frag in_f)
      {
          OUT_Data_Frag out_f;
          out_f.SV_Target0 = float4(0, 0, 0, 0);
          return out_f;
      }
      
      
      ENDCG
      
    } // end phase
  }
  FallBack ""
}
